﻿<%@ Page MasterPageFile="~/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="ShipRuleShow.aspx.cs" Inherits="RabbitManage.UI.ShipRuleShow" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <form id="form1" action="/Action/ShipRuleCityAdd.aspx" method="POST">
        
        <h3>特殊城市运费:</h3>

        <script type="text/javascript">

            form1.onsubmit = function (e) {
                e.preventDefault();

                var data = [];
                var price = document.getElementById("inputBaseCost");
                var inputs = document.getElementsByName("city");
                for (var j = 0; j < inputs.length; j++) {
                    var input = inputs[j];
                    if (input.checked) {
                        var cost = {};
                        cost["Region"] = input.value;
                        cost["Cost"] = price.value;
                        data.push(cost);
                    }
                }
                
                var xhr = new XMLHttpRequest();
                xhr.open(form1.method, form1.action, true);
                xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');

                xhr.send(JSON.stringify(data));

                xhr.onloadend = function () {
                    // done
                    if (xhr.responseText == "true") {
                        window.location = "/UI/ShipRuleCity.aspx";
                    } else {
                        alert(xhr.responseText);
                    }
                };
            };
            
        </script>
        
        <table>
            <tr>
                <td style="width: 10em;">
                    <table>
                        <tr>
                            <td style="width: 4em;text-align: left;">省份</td>
                            <td style="width: 3em;text-align: right;">运费</td>
                            <td style="width: 3em;text-align: center;"><a href="ShipRuleProvince.aspx">修改</a></td>
                        </tr>
                <asp:Repeater runat="server" ID="costRepeater" >
                    <ItemTemplate>
                        <tr>
                            <td style="width: 4em;"><label title="<%#Eval("Key") %>"><%#Eval("Key") %></label></td>
                            <td style="width: 3em;text-align: right;"><label><%#Eval("Value") %></label></td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                    </table>
                </td>
                
                <td style="vertical-align: top; width: 240px;">
                    <table style="vertical-align: top;" >
                        <tr>
                            <td style="text-align: left;">城市</td>
                            <td style="text-align: right;">运费</td>
                            <td style="width: 3em;"><a href="ShipRuleCity.aspx" >修改</a></td>
                        </tr>
                        
                <asp:Repeater runat="server" ID="cityRepeater" >
                    <ItemTemplate>
                        <tr>
                            <td style="width: 7em"><label title="<%#Eval("Key") %>" ><%#Eval("Key") %></label></td>
                            <td style="width: 3em; text-align: right;" ><label ><%#Eval("Value") %></label></td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                        
                    </table>
                    
                </td>
            </tr>
        </table>
        
    </form>
    
</asp:Content>